package install.ren.exercise.test.netty;

import io.netty.buffer.ByteBuf;

/**
 * Created by wangxiaoxu on 17/2/14.
 */
public class MessageBuilder {

    public static Message buildMsg(ByteBuf byteBuf) {
        Message message = new TestMessage();
        int length = byteBuf.readInt();
        int commandId = byteBuf.readInt();
        System.out.println("comandId:" + commandId);


        if (message != null) {
            message.setLength(length);
            message.setCmdId(commandId);
            int seqId = byteBuf.readInt();
            message.setSeqId(seqId);
            message.setSeqId1(byteBuf.readInt());
            message.setSeqId2(byteBuf.readInt());
            message.toMessage(byteBuf);
        }
        return message;
    }
}

